<include file="../header" />
<div class="wrapper">
    <div class="header text-center font-16">
        评价
        <div class="iconfont icon-zuo go_back"></div>
    </div>
    <div class="history-list padding-12">
        <div class="evaluate">
            <span class="gray">服务态度：</span>
            <span class="star" id="service_star">
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
            </span>
        </div>
        <div class="evaluate">
            <span class="gray">维修质量：</span>
            <span class="star" id="quality_star">
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
            </span>
        </div>
        <div class="evaluate">
            <span class="gray">响应速度：</span>
            <span class="star" id="answer_star">
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
                <span class="iconfont icon-xingxing starr"></span>
            </span>
        </div>
        <textarea class="textarea2" name="comment" id="comment" cols="30" rows="10" placeholder="对本次报修服务感觉怎么样？来说说吧~"></textarea>
    </div>
    <a href="#" class="btn add text-center">提交评价</a>
</div>
<input type="hidden" id="order_id" value="{BEESCRM:$order_id}">
<script src="/assets/repaireast/js/layer.js"></script>
<script src="/assets/repaireast/js/public.js"></script>
<script>
    $('.star').on('click','.icon-xingxing',function () {
        /*  for (var i = 0; i <= idx; i++) {
         $('.icon-xingxing').eq(i).addClass('xingxing');
         }*/
        $(this).addClass('xingxing').prevAll().addClass('xingxing');
        $(this).nextAll().removeClass('xingxing');
    });

    $('.add').click(function(){
        var service_star = $('#service_star .xingxing').size()
        var quality_star = $('#quality_star .xingxing').size();
        var answer_star = $('#answer_star .xingxing').size();
        var comment = $('#comment').val();

        if (service_star < 1){
            fm.alert('请评价服务态度！');
            return false;
        }
        if (quality_star < 1){
            fm.alert('请评价维修质量！');
            return false;
        }
        if (answer_star < 1){
            fm.alert('请评价响应速度！');
            return false;
        }

        $.ajax({
            type:'post',
            url:"/Repaireast/RepaireastRepair/doComment",
            dataType:'json',
            data:{
                'order_id' : $('#order_id').val(), 'service_star':service_star, 'quality_star':quality_star, 'answer_star':answer_star, 'comment':comment
            },
            success:function(data){
                fm.alert(data.message);
                setTimeout(function(){
                    var url = '/Repaireast/RepaireastRepair/orderDetail/order_id/'+data.id;
                    window.location.href = url;
                },2000);
            },
            error:function(){
                fm.alert('通讯失败，请稍后再试');
            }
        });
    });
</script>
<include file="../footer" />